package com.hzjq.core.impl

import com.hzjq.core.ErrorCode
import com.hzjq.core.callback.OnVersionCallback
import com.hzjq.core.loader.OnVersionLoader
import com.hzjq.core.work.Works
import com.hzjq.core.worker.VersionWork
import io.reactivex.functions.Consumer

class VersionImpl : OnVersionLoader {

    override fun getVersion(callback: OnVersionCallback) {
        CheckerImpl().setCallback(Consumer {
            if (it) {
                Works.Builder.newBuilder()
                    .addWork(VersionWork(callback))
                    .build()
                    .queue()
            } else {
                callback.onError(ErrorCode.getErrorResult(103))
            }
        }).start()
    }
}